<?php session_start(); ?>
<!DOCTYPE html>
<html lang="cn" dir="ltr" class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="maximum-scale=1.0,width=device-width,initial-scale=1.0,user-scalable=no">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>异步 </title>
    <link href="/public/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/public/assets/css/style.css" rel="stylesheet" />
    <link href="/public/assets/css/nprogress.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/assets/css/nivo-slider.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="/public/assets/css/default.css" type="text/css" media="screen" />
    <script src="/public/assets/js/jquery.min.js"></script>
    <script src="/public/assets/js/jquery.nivo.slider.pack.js"></script>
    <script src="/public/assets/js/nprogress.js"></script>
</head>
<style>
    #middle1-search{
        height: 32px;
        width: 200px;
        /*position: absolute;*/
        margin-top: 10px;
        right:60px;
        border-radius: 30px;
        font-size: 14px;
        color: rgb(153,153,153);
        background-color: rgb(235,236,237);
        border: none;
    }
    #middle1-search:focus {
        outline:none;
        box-shadow:0 0 0 1.5px #f7941d;    //设置圆角边框 
    }
</style>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">
              Toggle navigation
            </span>
                <span class="icon-bar">
            </span>
                <span class="icon-bar">
            </span>
                <span class="icon-bar">
            </span>
            </button>
            <a class="navbar-brand" href="index.html">
                <img src="/public/assets/img/logo.png" class="logo"/>
            </a>
        </div>
        <div class="collapse navbar-collapse " id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav header-menu">
                <li>
                    <a href="/index.php?c=index&a=index">
                        首页
                    </a>
                </li>

                <li>
                    <a href="/index.php?c=Publish&a=links">
                        发布文章
                    </a>
                </li>

                <li>
                    <a href="/index.php?c=infomation&a=localInfo">
                        个人信息
                    </a>
                </li>
                <li>
                    <input id="middle1-search" type="text" placeholder="     请输入关键字搜索" onkeyup="research(event)" />
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="leftbar">
    <!-- 左菜单 -->
    <div class="left_menu">
        <ul class="menu_link">
            <?php if(!$_SESSION['logname']){ ?>
            <li>
                <a href="/index.php?c=Login&a=LoginFucntion" class="simptip-position-right simptip-smooth simptip-movable"
                   data-toggle="tooltip" data-placement="right" title="登录">
                    <img src="/public/assets/img/login.png">
                    <span>登录</span>
                    <div class="clearfix">
                    </div>
                </a>
            </li>
            <li data-toggle="tooltip" data-placement="right" title="注册">
                <a href="/index.php?c=Register&a=RegisterFunction" class="simptip-position-right simptip-smooth simptip-movable"
                   target="_black">
                    <img src="/public/assets/img/regist.jpg">
                    <span>
                注册
              </span>
                    <div class="clearfix">
                    </div>
                </a>
            </li>
            <li>
                <a href="index.php?c=Publish&a=links" class="simptip-position-right simptip-smooth     simptip-movable" title="发文章">
                    <img src="/public/assets/img/book.jpg">

                    <div class="clearfix">
                    </div>
                </a>
            </li>
            <?php }else{ ?>
                <?php if ($_SESSION['type']=='1'){ ?>
            <li>
                <a href="/index.php?c=Login&a=logOut" class="simptip-position-right simptip-smooth simptip-movable"
                   data-toggle="tooltip" data-placement="right" title="退出">
                    <img src="/public/assets/img/pig.jpg">
                    <div class="clearfix">
                    </div>
                </a>
            </li>
                <?php }else if ($_SESSION['type']=='2'){ ?>
                    <li>
                        <a href="index.php?c=Publish&a=links" class="simptip-position-right simptip-smooth     simptip-movable" title="发文章">
                            <img src="/public/assets/img/book.jpg">

                            <div class="clearfix">
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="/index.php?c=Login&a=logOut" class="simptip-position-right simptip-smooth simptip-movable"
                           data-toggle="tooltip" data-placement="right" title="退出">
                            <img src="/public/assets/img/pig.jpg">

                            <div class="clearfix">
                            </div>
                        </a>
                    </li>
                <?php }else{ ?>
                    <li>
                        <a href="" class="simptip-position-right simptip-smooth     simptip-movable" title="权限管理">
                            <img src="/public/assets/img/manager.jpg">
                            <span>
                权限管理
              </span>
                            <div class="clearfix">
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="index.php?c=Publish&a=links" class="simptip-position-right simptip-smooth     simptip-movable" title="发文章">
                            <img src="/public/assets/img/book.jpg">

                            <div class="clearfix">
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="/index.php?c=Login&a=logOut" class="simptip-position-right simptip-smooth simptip-movable"
                           data-toggle="tooltip" data-placement="right" title="退出">
                            <img src="/public/assets/img/pig.jpg">

                            <div class="clearfix">
                            </div>
                        </a>
                    </li>
               <?php } ?>
            <?php } ?>
    </div>
</div>
<!--Start banner img-->
<!-- 轮播图 -->
<div class="container-filed" id="banner_container">
    <div class="row">
        <div class="col-md-12">
            <div class="slider-wrapper theme-default">
                <div id="slider" class="nivoSlider">
                    <img src="/public/assets/img/left1.jpg" data-thumb="/public/assets/img/left1.jpg" alt="" />
                    <a href="/public/assets/img/left2.jpg"><img src="/public/assets/img/left2.jpg" alt="" /></a>
                    <img src="/public/assets/img/left1.jpg" data-thumb="/public/assets/img/left1.jpg" alt="" />
                    <img src="/public/assets/img/left4.jpg" data-thumb="/public/assets/img/left4.jpg" alt="" />
                </div>
            </div>
        </div>
    </div>
</div>
<!--End banner img-->
<!--主要内容 -->
<div class="container-fluid main-container" id="main-container">
    <div class="row top-title">
        <div class="col-md-12">
            <h1 class="page-title">
                最新文章
            </h1>
        </div>
    </div>
    <!--main Start-->
    <div class="row" id="rows1">
        <div class="col-md-12 post-container">
            <h2 class="post-title">
                <a href="content.html" title=""><?php echo $title1; ?></a>
            </h2>
            <div class="meta-box">
            <span class="m-post-date">
              <i class="fa fa-calendar-o">
              </i>
              <?php echo $updated_at1; ?>
            </span>
                <span class="comments-link">
              <a href="" class="ds-thread-count" data-thread-key="9500" title="Comment on 毕业两周年">
                  <i class="fa fa-comments-o">
                  </i>
                  <?php echo $name1; ?>
              </a>
            </span>
            </div>
            <div class="post-content">
                <p>
                    <?php echo $content1; ?>
                    <a href="http://www.ybsat.com">
                        联系我
                    </a>
                </p>
            </div>
            <div class="meta-box">

                <span class="tag-links">
              <i class="fa fa-tags">
              </i>
              <b>
                  标签:
              </b>
              <a href="tags/毕业.htm" rel="tag">
                  <?php echo $tags1 ?>
              </a>
            </span>
            </div>
        </div>
    </div>
    <div class="row"  id="rows2">
        <div class="col-md-12 post-container">
            <h2 class="post-title">
                <a href="content.html" title=""><?php echo $title2; ?></a>
            </h2>
            <div class="meta-box">
            <span class="m-post-date">
              <i class="fa fa-calendar-o">
              </i>
              <?php echo $updated_at2; ?>
            </span>
                <span class="comments-link">
              <a href="" class="ds-thread-count" data-thread-key="9500" title="Comment on 毕业两周年">
                  <i class="fa fa-comments-o">
                  </i>
                  <?php echo $name2; ?>
              </a>
            </span>
            </div>
            <div class="post-content">
                <p>
                    <?php echo $content2; ?>
                </p>
            </div>
            <div class="meta-box">
                <span class="tag-links">
              <i class="fa fa-tags">
              </i>
              <b>
                  标签:
              </b>
              <a href="tags/毕业.html" rel="tag">
                  <?php echo $tags2; ?>
              </a>
            </span>
            </div>
        </div>
    </div>
    <div id="shows">

    </div>
    <!--更多内容-->
    <div class="row">
        <div class="col-md-12">
            <h2 class="page-title">
                <a href="blog.html" title="">更多内容</a>
            </h2>
        </div>
    </div>
    <!--跳转至博客页面-->
    <div class="row">
        <div class="col-md-12 post-container">
            <div class="row">
                <div class="col-md-4">
                    <a class="btn btn-primary home-browser-more-btn" href="blog.html">
                        <span>浏览更多文章</span>
                    </a>
                </div>
                <div class="col-md-8">
                </div>
            </div>
        </div>
    </div>
    <!--推荐阅读-->
    <div class="row">
        <div class="col-md-12 post-container m-recommend-page">
            <div class="row">
                <div class="col-md-4">
                    <a href="" class="thumbnail">
                        <img src="/public/assets/img/works.png" alt="作品展示">
                    </a>
                </div>
                <div class="col-md-4">
                    <a href="" class="thumbnail">
                        <img src="/public/assets/img/about.png" alt="路人简介">
                    </a>
                </div>
                <div class="col-md-4">
                    <a href="" class="thumbnail">
                        <img src="/public/assets/img/book.png" alt="作品推荐">
                    </a>
                </div>
            </div>
        </div>
    </div>

</div>
<script src="/public/assets/js/bootstrap.min.js"></script>
<script>
    /*banner 初始化*/
    $(window).load(function() {
        $('#slider').nivoSlider({
            effect: 'random',        // 过渡效果
            controlNav: false,       // 是否显示图片导航控制按钮（,2,3... ）
            pauseOnHover: true,      // 鼠标县浮时是否停止动画
            manualAdvance: false,    // 是否手动切换
            animSpeed: 100,          // 图片过渡时间
            pauseTime: 2000,         // 图片显示时间
            pauseOnHover: false,
            manualAdvance: false,
        });
    });
    $(document).ready(function(){
        $('body').show();
        $('.version').text(NProgress.version);
        NProgress.start();
        setTimeout(function() { NProgress.done(); $('.fade').removeClass('out'); }, 1000);
    })

    function indexclick() {

        location.href="/index.php?c=Login&a=logOut";
    }

    function research(e){
        if(e.keyCode==13){
            var a = document.getElementById('middle1-search').value
            if (a==""){
                alert("字段为空，请输入关键字搜索");
            }else{
                $.ajax({
                    url:"/index.php?c=ESTest&a=filesMatch",
                    type:"POST",
                    data:{
                        Kwords:a
                    },
                    dataType:"json",
                    success:function (data){
                        if (data.length!=0){
                            var div1=document.getElementById("rows1");
                            var div2=document.getElementById("rows2");
                            div1.style.display='none';
                            div2.style.display='none';
                            console.log(data.length);
                            var blog='';
                            for (var i=0;i<data.length;i++){
                                var articls=data[i]._source;
                                blog +="<div class=\"col-md-12 post-container\">\n" +
                                    "            <h2 class=\"post-title\">\n" +
                                    "                <a href=\"content.html\" title=\"\">"+articls.title+"</a>\n" +
                                    "            </h2>\n" +
                                    "            <div class=\"meta-box\">\n" +
                                    "            <span class=\"m-post-date\">\n" +
                                    "              <i class=\"fa fa-calendar-o\">\n" +
                                    "              </i>\n" +
                                    "               "+articls.updated_at+"\n" +
                                    "            </span>\n" +
                                    "                <span class=\"comments-link\">\n" +
                                    "              <a href=\"\" class=\"ds-thread-count\" data-thread-key=\"9500\" title=\"Comment on 毕业两周年\">\n" +
                                    "                  <i class=\"fa fa-comments-o\">\n" +
                                    "                  </i>\n" +
                                    "                  "+articls.uid+"\n" +
                                    "              </a>\n" +
                                    "            </span>\n" +
                                    "            </div>\n" +
                                    "            <div class=\"post-content\">\n" +
                                    "                <p>\n" +
                                    "                    "+articls.content+"\n" +
                                    "                    <a href=\"http://www.ybsat.com\">\n" +
                                    "                        联系我\n" +
                                    "                    </a>\n" +
                                    "                </p>\n" +
                                    "            </div>\n" +
                                    "            <div class=\"meta-box\">\n" +
                                    "\n" +
                                    "                <span class=\"tag-links\">\n" +
                                    "              <i class=\"fa fa-tags\">\n" +
                                    "              </i>\n" +
                                    "              <b>\n" +
                                    "                  标签:\n" +
                                    "              </b>\n" +
                                    "              <a href=\"tags/毕业.htm\" rel=\"tag\">\n" +
                                    "                  "+articls.tags+"\n" +
                                    "              </a>\n" +
                                    "            </span>\n" +
                                    "            </div>\n" +
                                    "        </div>";
                            }
                            var divs = document.getElementById("shows");
                            divs.innerHTML=blog;
                        }else{
                            var div1=document.getElementById("rows1");
                            var div2=document.getElementById("rows2");
                            div1.style.display='none';
                            div2.style.display='none';
                            var divs = document.getElementById("shows");
                            divs.innerHTML="<h2>抱歉！未搜索到您需要的内容，请重新搜索</h2>";
                        }
                    },
                    error:function (){
                        alert("请求失败")
                    }
                });
            }
        }
    }
</script>

</body>

</html>